home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 June / Ahoy_Magazine_87-06_1987_Double_L.d64 / Power Squares (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  3KB  |  129 lines

  1. 10 poke53280,0:poke53281,0:poke828,1
  2. 20 print"[147]"tab(13)"power squares"
  3. 30 printtab(93)"by john fedor"
  4. 40 gosub680:gosub960:print"   how many players (d, 1 or 2) ? ";
  5. 50 poke198,0
  6. 60 geta$:if(a$<"1"ora$>"2")anda$<>"d"then60
  7. 70 printa$
  8. 80 pl=val(a$)
  9. 90 dim a(5,5):rem the grid
  10. 100 z=1:pokev,100:pokev+1,76
  11. 110 fory=1to5:forx=1to5
  12. 120 ifx=3andy=3then140
  13. 130 a(x,y)=z+1
  14. 140 z=1-z:nextx,y
  15. 150 print"[147]":tu=1
  16. 151 print""tab(32)"[159][172][162][162][162][162][162][187]"
  17. 152 printtab(32)"[161]     [146][159][161]"
  18. 153 printtab(32)"[161]     [146][159][161]"
  19. 154 printtab(32)"[161]    [146][159][161]"
  20. 155 printtab(32)"[161]     [146][159][161]"
  21. 156 printtab(32)"[161]     [146][159][161]"
  22. 157 printtab(32)"[188][162][162][162][162][162][146][190]"
  23. 158 print""
  24. 160 printtab(11)"[159]                 [146]"
  25. 170 fory=1to15
  26. 180 printtab(11)"  "
  27. 190 nexty
  28. 200 printtab(11)"[159]                 [146]"
  29. 210 c$(1)="":c$(2)="":c$(0)="[144]":wi=0
  30. 220 print""tab(12);:fory=1to5:forx=1to5
  31. 230 printc$(a(x,y))"   [157][157][157]   [157][157][157]   [145][145]";
  32. 240 nextx:print""chr$(13)tab(12):nexty
  33. 245 ifwi<>0then800
  34. 250 t$(1)="blue":t$(2)="red"
  35. 260 print""t$(tu)"'s turn ":pokev+21,1
  36. 270 iftu=2andpl=1orpl=0then750
  37. 280 if(peek(56322-tu)and16)<>16then280
  38. 290 x=(peek(v)-100)/24+1
  39. 300 y=(peek(v+1)-76)/24+1
  40. 310 j=(peek(56322-tu)and15)
  41. 320 if(jand1)=1theny=y+1
  42. 330 if(jand2)=2theny=y-1
  43. 340 if(jand4)=4thenx=x+1
  44. 350 if(jand8)=8thenx=x-1
  45. 360 ifx=0thenx=1
  46. 370 ifx=6thenx=5
  47. 380 ify=0theny=1
  48. 390 ify=6theny=5
  49. 400 pokev,100+(x-1)*24:pokev+1,76+(y-1)*24
  50. 410 if(peek(56322-tu)and16)=16then290
  51. 420 ifa(x,y)<>tuthen290
  52. 422 rem compare to see if on same x / y
  53. 430 fori=-5to5:ifx+i<1orx+i>5then443
  54. 432 ifa(x+i,y)<>0 then 443
  55. 435 k=sgn(i):for i1= i to 0 step-k
  56. 437 if x+i1-k<1 or x+i1-k>5then440
  57. 438 a(x+i1,y)=a(x+i1-k,y)
  58. 440 nexti1:goto480
  59. 443 nexti
  60. 445 fori=-5to5:ify+i<1ory+i>5then455
  61. 446 ifa(x,y+i)<>0 then 455
  62. 447 k=sgn(i):for i1=i to 0 step-k
  63. 448 if y+i1-k<1 or y+i1-k>5then451
  64. 450 a(x,y+i1)=a(x,y+i1-k)
  65. 451 nexti1:goto480
  66. 455 nexti
  67. 470 goto270
  68. 480 a(x,y)=0
  69. 490 tu=tu+1:iftu=3thentu=1
  70. 500 fory1=-5to5:forx1=-5to5
  71. 510 ifx1<>0 and y1<>0then550
  72. 520 ify+y1<1ory+y1>5orx+x1<1orx+x1>5then550
  73. 530 ifa(x+x1,y+y1)<>tuthen550
  74. 540 fory1=1to1:forx1=1to1:nextx1,y1:goto560
  75. 550 nextx1,y1:goto490
  76. 560 fory=1to2:forx=1to5:ifa(x,y)=1thennextx,y:ifa(1,3)=1anda(2,3)=1thenwi=1
  77. 570 fory=4to5:forx=1to5:ifa(x,y)=2thennextx,y:ifa(4,3)=2anda(5,3)=2thenwi=2
  78. 580 goto220
  79. 600 data0,0,0,0,0,0,0,0
  80. 610 data0,0,0,0,0,0,0,0
  81. 620 data0,0,0,0,0,0,127,252
  82. 630 data0,127,252,0,96,12,0,96
  83. 640 data12,0,96,12,0,96,12,0
  84. 650 data96,12,0,96,12,0,96,12
  85. 660 data0,96,12,0,127,252,0,127
  86. 670 data252,0,0,0,0,0,0,0
  87. 680 fori=0to63:reada:poke832+i,a:nexti
  88. 685 fori=49152to49206:reada:pokei,a:next:sys49152
  89. 690 v=53248
  90. 700 pokev+21,0:pokev+23,1:pokev+29,1
  91. 710 pokev+28,0:pokev+39,1
  92. 720 poke2040,13
  93. 730 pokev,148:pokev+1,124
  94. 740 return
  95. 750 rem computer's turn
  96. 755 y1=int(rnd(1)*5)+1
  97. 760 x1=int(rnd(1)*5)+1
  98. 764 ift4(tu)=x1+(y1)*6then755
  99. 766 t4(tu)=x+(y)*6
  100. 767 pokev,76+(x1)*24:pokev+1,52+(y1)*24
  101. 770 ifa(x1,y1)<>tuthen755
  102. 780 x=x1:y=y1:goto420
  103. 800 rem end of game
  104. 810 pokev+21,0
  105. 820 forx=0to255:poke53281,x:poke53280,255-x:nextx
  106. 830 poke53280,0:poke53281,0
  107. 840 x1=2:ifwi=1thenx1=6
  108. 850 poke53280,x1
  109. 860 print"[147]"t$(wi)" won!!!"
  110. 870 printtab(6)"press <return> to play again"
  111. 875 printtab(7)"or press either firebutton"
  112. 880 poke198,0
  113. 890 geta$:ifa$<>chr$(13)and(peek(56321)and16)=16and(peek(56320)and16)=16then890
  114. 895 poke198,0:run
  115. 900 data120,169,13,141,20,3,169,192
  116. 910 data141,21,3,88,96,172,60,3,136
  117. 920 data140,60,3,208,24,160,5,140,60
  118. 930 data3,174,61,3,189,49,192,141,39
  119. 940 data208,232,224,6,208,2,162,0,142
  120. 950 data61,3,76,49,234,1,3,14,6,14,3
  121. 960 print""tab(17)"     "
  122. 962 forx=1to3
  123. 965 printtab(17)"     "
  124. 970 nextx
  125. 975 printtab(17)"     [146]"
  126. 980 print""
  127. 990 pokev,149:pokev+1,164:pokev+21,1
  128. 995 return
  129.